
/*
 * SpotTakenFrame.java
 *
 * Created on Jul 30, 2011, 2:35:24 AM
 */
package client.parkingdisplay;

/**
 *
 * @author Team 5
 */
public class SpotTakenFrame extends javax.swing.JFrame {

    /*
     * boolean variable that represents wheter an action 
     * has been taken by the user or not
     */
    private boolean action = false;
    /** Creates new form SpotTakenFrame */
    public SpotTakenFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        leaveButton = new javax.swing.JButton();
        spotNumberLabel = new javax.swing.JLabel();
        spotNotificationLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        leaveButton.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        leaveButton.setText("Leave");
        leaveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                leaveButtonActionPerformed(evt);
            }
        });

        spotNumberLabel.setFont(new java.awt.Font("Tahoma", 3, 20)); // NOI18N
        spotNumberLabel.setText("Spot #:");

        spotNotificationLabel.setFont(new java.awt.Font("Tahoma", 3, 20)); // NOI18N
        spotNotificationLabel.setText("Spot Notification");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(105, 105, 105)
                .addComponent(spotNumberLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(220, 220, 220))
            .addGroup(layout.createSequentialGroup()
                .addGap(117, 117, 117)
                .addComponent(leaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(136, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(88, 88, 88)
                .addComponent(spotNotificationLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                .addGap(128, 128, 128))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(spotNumberLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE)
                .addComponent(spotNotificationLabel)
                .addGap(45, 45, 45)
                .addComponent(leaveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(57, 57, 57))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /*
     * called when the user presses the leave button
     */
    private void leaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_leaveButtonActionPerformed

        action = true;
    }//GEN-LAST:event_leaveButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new SpotTakenFrame().setVisible(true);
            }
        });
    }
    
    /**
     * updates the text named spotNumberLabel
     * @param update contains the new message to be displayed
     */
    public void updateParkingSpotNumberLabel(String update)
    {
        spotNumberLabel.setText(update);
    }
    
    /**
     * updates the text named spotNotificationLabel
     * @param update contains the new message to be displayed
     */
    public void updateSpotNotificationLabel(String update)
    {
        spotNotificationLabel.setText(update);
    }
    
    /**
     * implements the Form interface
     * @return true iff an action has been performed on this screen by the user
     */
    synchronized public boolean displayNext()
    {
        if(action)
        {
            this.setVisible(false);
        }
        return action;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton leaveButton;
    private javax.swing.JLabel spotNotificationLabel;
    private javax.swing.JLabel spotNumberLabel;
    // End of variables declaration//GEN-END:variables
}
